<template>
	<view class="all-box">
		<!-- 404页面 -->
		<view class="noData" v-if="netWorkType == 'none'">
			<noData @handle="refresh"></noData>
		</view>
		<view v-if="netWorkType != 'none'">
			<!-- 顶部tab -->
			<!-- <view class="topTab">
				<view class="inner">
					<text @click="tabPageFun(index)" :class="topTabActive==index ? 'i-item topTabActive' : 'i-item'" v-for="(item,index) in topTab">
						{{item}}
					</text>
				</view>
			</view> -->
			<view class="main-content">

				<view class="inner-box">
					<view class="tab-view">
						<view class="inner">
							<view v-for="(item,index) in tabbar" class="tab-bar-item" :data-current="index" @tap.stop="swichNav">
								<text class="tab-bar-title" :class="[currentTab==index ? 'active active-color' : '']">{{item}}</text>
							</view>
						</view>
					</view>

					<!-- 线上订单 -->
					<view class="online-order-page">
						<view class="no-data-box" v-if="data.list.length<=0">没有更多数据</view>

						<view class="inner" v-for="(item,index) in data.list" @tap.stop="toDetail(item)">
							
							<view class="top-row">
								<view class="left-side" style="display: flex;">
									<!-- <text style="color:#fed369; font-size: 36rpx;" class="iconfont">&#xe676;</text> -->
									<view><img src="http://img.aiouning.com/uploader/upload/202202/11/202202110918506205b97a9deab.png" alt="" style="width: 40rpx;height: 40rpx;"></view>

									<text style="margin-left: 14rpx;">{{item.deliver_type==1?'门店自提':'配送上门'}}</text>
								</view>
								<view class="right-text">
									<!-- <text v-if="item.order_estate=='used_pending_payment'">租赁中</text> -->
									<!-- <text v-if="item.order_estate==''">运输中</text> -->
									<text v-if="item.order_estate=='32'">已完成</text>
									<text v-if="item.order_estate=='pending_payment'">未付款</text>
									<text v-if="item.order_estate=='sign_for'">已签收</text>
									<text v-if="item.order_estate=='2'">待发货</text>
									<!-- <text v-if="item.order_estate=='4'"></text> -->
									<text v-if="item.order_estate=='12'">正在配送</text>
									<text v-if="item.order_estate=='16'">待上传</text>
									<text v-if="item.order_estate=='17'">待确认</text>
								</view>
							</view>
							<view class="main-row" v-for="v in item.sub">
								<view class="main-img">
									<image :src="v.cover_image" mode="widthFix"></image>
								</view>
								<view class="main-info">
									<view class="name">{{v.related_name}}</view>
									<view class="desc">{{v.norms_value_name|| ''}}</view>
									<view class="desc">费用：{{v.amount}}</view>
									<view class="desc" >x{{v.related_num}}</view>
									<!-- <view class="desc" v-if="item.use_start_at!=''" >套餐期限：{{item.use_start_at}}~{{item.use_expire_at}}</view> -->
									
								</view>
							</view>
							<view class="bottom-row">
								<view class="left-side" style="font-size: 24rpx; color: #888;">
									费用：<text class="price-val">￥{{item.amount}}</text>
									<view>{{item.createTime}}</view>
								</view>
								<view class="right-action">
									
									<!-- <view class="btn-action" v-if="item.order_estate=='used_pending_payment'" @tap.stop="lossPayPop(item.id,item.name,item.self_custom_amount,item.cash,item.related_type)">申请赔付</view> -->
									<!-- <view class="btn-action blue" v-if="item.order_estate=='used_pending_payment'" @tap.stop="getPayStore(item,'online')">申请归还</view>
									<view class="btn-action blue" v-if="item.order_estate=='completed'" @tap.stop="goShopDetail(item)">再次租赁</view> -->
									<!-- <view class="btn-action blue" v-if="item.order_estate=='pending_payment'" @tap.stop="getPayStore(item,'online')">付款</view> -->
									<view class="btn-action blue" v-if="item.order_estate=='shipping'" @tap.stop="receive(item)">签收</view>
									<view class="btn-action blue" v-if="item.order_estate=='16'| item.order_estate=='17'" @tap.stop="upPubpay(item)">上传凭证</view>
									<view class="btn-action blue" v-if="item.order_estate=='16'| item.order_estate=='17'|item.order_estate=='1'"  @tap.stop="cancelOrder(item)">取消订单</view>
								</view>
							</view>
						</view>
					</view>

				</view>
				



			</view>
			<!-- 上传凭证 -->
			<uni-popup ref="upPubpayModal" type="bottom" :custom="true" >
				<view class="upPubpay-box">
					<view class="title">
						上传对公转账凭证
					</view>	
					<!-- <view class="text">
						确认退款
					</view> -->
					<view class="closs" @tap.stop="$refs.upPubpayModal.close()">
						x
					</view>
					<view class="content " >
						<view class="tip">
							温馨提示：上传转账凭证图和凭证上的流水号或凭证号等，<span style="color: red;">如果无法上传图片，联系客服帮您处理图片上传，</span>3天内未上传转账凭证和流水号将自动取消该订单.
						</view>
						<view class="tip-box">
							<view class="">
								<view class="txt">上传对公凭证(限制2M以内)：</view>
								<view class="input-box"><tui-upload :limit="2" :dirType="0" :userType="2" :serverUrl="serverUrl" @complete="result($event,'pubpay_img')" @remove="remove($event,'pubpay_img')"></tui-upload></view>
							</view>
							<view class="tip-txt">
								<view class="txt">流水号：</view>
								<view class="input-box"><input type="text" name="" v-model="callback_trade_no" placeholder="请输入凭证上的流水号或凭证号" ></view>
							</view>
							
							<view class="tip-txt">
								<view class="txt">公司名称：</view>
								<view class="input-box">广西瓯宁医疗科技有限公司</view>
							</view>
							<view class="tip-txt">
								<view class="txt">开户行：</view>
								<view class="input-box">兴业银行南宁分行</view>
							</view>
							<view class="tip-txt">
								<view class="txt">税号：</view>
								<view class="input-box">9145010006174381XR</view>
							</view>
							<view class="tip-txt">
								<view class="txt">账号：</view>
								<view class="input-box">552010100100607698</view>
							</view>
							<view class=" tip-btn" @tap.stop='copyText'>
								<view class="iconfont">
									&#xe661;
								</view>
								<view class="txt">
									复制
								</view>
							</view>
							<view class="" style="height: 100rpx;">
								
							</view>
						</view>
						
						
					</view>	
					<view class="footer">
						<!-- <view class="btn-close btn">
							取消
						</view> -->
						<view class="btn-comfir btn" @tap.stop = "upPubpayImg()">
							确认提交
						</view>
					</view>
				</view>
				
			</uni-popup>

			<!-- 赔付弹框    结束-->
			<!-- 提示弹框 -->
			<tui-tips ref="toast"></tui-tips>

			<!-- 登录弹框 -->
			<uni-popup-vlogin id="popupvLogin" ref="popupvLogin" type="bottom" />
			<!-- 共用底部 -->
			<!-- <btabbar @camera="camera"></btabbar> -->
			<!-- 共用底部end1 -->
		</view>
	</view>
</template>

<script>
	// 公共底部
	// import btabbar from '@/components/indexBottomTable/bottomtabbar.vue'
	import tuiUpload from '@/components/tui-upload/tui-upload'
	//获取网络状态
	import {
		mapGetters
	} from 'vuex';
	
	export default {
		data() {
			return {

				data: {
					list: [],

				},
				type: 'bottom',
				lossProductName: '', //丢失产品名称
				lossOrderId: '', //丢失产品id
				lossSelfCustomAmount: '', //丢失产品
				lossRelatedType: '', //丢失产品类型
				currentTab: 0, //预设当前项的值
				tabbar: ["全部", "待付款","待发货", "待收货", "待评价", "已完成"],
				storetabbar: ["全部", "进行中", "已完成"],
				cashtabbar: ["全部", "绑定中", "可提现"],
				speciOrderTabbar:["全部", "待支付", "已支付"],
				order_estate: '', //
				winHeight: "", //窗口高度
				currentTab: 0, //预设当前项的值
				scrollLeft: 0, //tab标题的滚动条位置
				loadingText: '加载中...',
				loadingType: 3, //定义加载方式 0---contentdown  1---contentrefresh 2---contentnomore 3-----contentfirst
				contentText: {
					contentdown: '上拉显示更多',
					contentrefresh: '正在加载...',
					contentnomore: '没有更多数据了',
					contentfirst: "暂无数据"
				},
				curr_page: 0, //当前页
				last_page: 0, //总页数
				topTabActive: 1,
				topTab: ["门店订单","配送上门",  "我的押金","特殊订单"],
				sourceUrl: '',
				selectMonthCard:{},
				serverUrl:'',//上传图片链接
				pubpay_img:[],
				callback_trade_no:'',
				up_trade_no:'',

			}
		},
		components: {
			// btabbar
			tuiUpload
		},
		computed: {
			//注册网络状态
			...mapGetters(['netWorkType'])
		},
		onLoad: function(option) {
			this.sourceUrl = option.url;
			this.serverUrl = this.$service.getImgHost()
			if (option.topTabActive) {
				// this.topTabActive = option.topTabActive;
				this.sourceUrl = '';
				this.curr_page = 0;
				// this.getStoreList()

			}
			
			let cur= this.currentTab = option.currentTab?option.currentTab:0;
			if (cur == 1) {
				//待付款
				this.order_estate = 'pending_payment'
			}
			
			if (cur == 2) {
			
				//待发货
				this.order_estate ='paid'
			}
			
			if (cur == 3) {
				//待收货    配送中
				this.order_estate = 'shipping'
			}
			if (cur == 4) {
				//已签收 待评价
				this.order_estate = 'sign_for'
			}
			
			if (cur == 5) {
				//已完成
				this.order_estate = 'completed'
			}
			
			if (cur == 0) {
				//全部
				this.order_estate = ''
			}
			
			
			console.log('*********',this.currentTab)
			console.log(this.order_estate)

		},
		onShow() {

			// #ifdef MP-WEIXIN
			if (wx.hideHomeButton) {
				wx.hideHomeButton();
			}
			// #endif

			if (this.sourceUrl) {

				// this.curr_page = 0;
				// this.getStoreList()

			}
			this.curr_page = 0
			switch (this.topTabActive) {
				case 1:
					this.getList();
					break
			
			// 	case 0:
			// 		this.getStoreList();
			// 		break
			
			// 	case 2:
			// 		this.getCashList();
			// 		break
			// 	case 3:
			// 		case 3:
			// 			// 特殊押金
						
			// 			this.getOutProcessList();
			// 			break;
			// 		break
			}
			// this.curr_page = 0;
			// this.getStoreList()
			//this.getList()

		},
		onPullDownRefresh: function() {
			//下拉刷新的时候请求一次数据
			this.curr_page = 0
			this.loadingType = 3;
			this.getList();
			// switch (this.topTabActive) {
			// 	case 1:
			// 		this.getList();
			// 		break

			// 	case 0:
			// 		this.getStoreList();
			// 		break

			// 	case 2:
			// 		this.getCashList();
			// 		break
			// 	case 3:
			// 		this.getOutProcessList();
			// 		break
			// }

		},
		onReachBottom: function() {
			//触底的时候请求数据，即为上拉加载更多
			//为了更加清楚的看到效果，添加了定时器
			if (this.curr_page >= this.last_page) {
				uni.showToast({
					icon: 'none',
					title: '没有更多数据'
				});

				this.loadingType = 2;
				return;
			}

			this.loadingType = 1;
			this.getList();
			// 正常应为:
			// switch (this.topTabActive) {
			// 	case 1:
					// this.getList();
			// 		break

			// 	case 0:
			// 		this.getStoreList();
			// 		break

			// 	case 2:
			// 		this.getCashList();
			// 		break
			// }


		},
		methods: {

			toDetail(item){
				const _this=this
				
				_this.$refer.setVilit('/pages/Order/orderDetail')

				let callback = function(url) {
					_this.$refs.popupvLogin.open()
				}
				
				var data ={
					list:JSON.stringify(item)
				}
				console.log(data)
				_this.$refer.toUrl(callback, data )
			},
			copyText() {
				let  text = '公司名称：广西瓯宁医疗科技有限公司\n开户行：兴业银行南宁分行\n税号：9145010006174381XR\n账号：552010100100607698'
			      uni.setClipboardData({	
			        data: text,
			        success: function () {
			          uni.showToast({
			            title: '复制成功',
			            icon: 'success',
			            duration: 2000
			          });
			        }
			      });
			},
			// 上传对公图片
			result: function(e,name) {
				
				if(name = 'pubpay_img'){
					this.pubpay_img = e.imgNameArr;
				}
				
				
				
				// console.log(this.pubpay_img,'******')
				// uni.setStorageSync('business_license', JSON.stringify(this.imageData));
			},
			remove: function(e,name) {
				//移除图片
				console.log(e)
				let index = e.index
				if(name = 'pubpay_img'){
					this.pubpay_img.splice(index, 1);
				}
				
				// console.log(this.pubpay_img,'******')
			},
			nowPay(id) {
			
				const _this = this
			
				let data = {
					id:id
				}
			
				
				// #ifdef  MP-WEIXIN || APP-PLUS
				//获取服务商
				var opt = {
					url: '/order/payOutOrder',
					data: data,
					success: function(res) {
						//console.log(res)
						if (res.status == 1) {
							
							
							// #ifdef  MP-WEIXIN
							uni.requestPayment({
								provider: 'wxpay',
								timeStamp: res.data.list.timeStamp,
								nonceStr: res.data.list.nonce_str,
								package: 'prepay_id=' + res.data.list.prepay_id,
								signType: 'MD5',
								paySign: res.data.list.paySign,
								success: function(res) {
			
									if (res.errMsg == 'requestPayment:ok') {
										let options = {
											msg: '支付成功',
											type: 'green'
										};
										_this.$refs.toast.showTips(options);
										_this.topTabActive=3;
										_this.curr_page=0;
										_this.getOutProcessList()
			
			// 							_this.$refer.setVilit('/packageUser/pages/user/pay/pay-success');
			
			// 							let callback = function(url) {
			// 								_this.$refs.popupvLogin.open()
			// 							}
			// 							var data = {
			// 								amount:res.data.list.payment,
			// 								product_name:''
			// 							}
			// 							_this.$refer.toUrl(callback, data, 'reLaunch')
			// 							return
									}
								},
								fail: function(err) {
									//console.log(err.errMsg)
									//console.log('fail:' + JSON.stringify(err));
									if (err.errMsg == 'requestPayment:fail cancel') {
			
										var opt = {
											url: '/coupon/clearCoupon',
											data: {
												order_no: store.getters.orderNo
												// order_no:"202010171849465f8acc4a24cca"
											},
											success: function(res) {
			
											},
										}
			
										_this.$service.GetApi(opt);
										let options = {
											msg: '取消支付',
											type: 'danger'
										};
										_this.$refs.toast.showTips(options);
										return
									} else {
										let options = {
											msg: JSON.stringify(err),
											type: 'danger'
										};
										_this.$refs.toast.showTips(options);
									}
								}
							});
							// #endif 	
			
						} else if (res.status == 0 && res.code == 1000) {
							//未付押金
							//些处pid为product表的id   
							// uni.navigateTo({
							// 	url:"../cash/cash?pid="+_this.productId
							// })
						} else {
			
							let options = {
								msg: res.message,
								type: 'danger'
							};
							_this.$refs.toast.showTips(options);
			
						}
			
					}
				};
			
				_this.$service.GetApi(opt)
				// #endif 
			
			},
			upPubpay(item){
				let _this = this
				_this.trade_no = item.trade_no
				_this.$refs.upPubpayModal.open()
			},
			// 用户上传对公凭证
			upPubpayImg(){
				
				let _this = this
				// console.log('payment_id轮询---', uni.getStorageSync('payment_id'))
				var opt = {
					url: '/order/pubpayImgUp',
					data: {
						trade_no: _this.trade_no,
						callback_trade_no:_this.callback_trade_no,
						pubpay_img:_this.pubpay_img||['1.png']
					},
					success: function(res) {
						if (res.status == 1) {
							// 取消成功
							// console.log(res)
							_this.$refs.upPubpayModal.close()
							_this.curr_page = 0
							_this.getList()
							
						} else {
							console.log(res.message)
						}
							
					}
				};
							
				uni.showModal({
					title: '温馨提示',
					content: '再次确认提交',
					success: function (res) {
						_this.$service.GetApi(opt) //网络
					}
				})
			},
			// 取消订单
			cancelOrder(item){
				// 用户取消支付 取消订单
				let _this = this
				// console.log('payment_id轮询---', uni.getStorageSync('payment_id'))
				var opt = {
					url: '/order/cancelOrder',
					data: {
						id: item.id
					},
					success: function(res) {
						if (res.status == 1) {
							// 取消成功
							console.log(res)
							_this.curr_page = 0
							_this.getList()
							
						} else {
							console.log(res.message)
						}
							
					}
				};
							
				uni.showModal({
					title: '提示',
					content: '确认取消该订单?',
					success: function (res) {
						_this.$service.GetApi(opt) //网络
					}
				})
			},
			// 刷新的方法
			refresh() {

			},
			tabPageFun(i) {
				this.topTabActive = i;
				this.order_estate = '';
				this.currentTab = 0;
				switch (i) {
					case 0:
						// 门店订单
						this.sourceUrl = '';
						this.curr_page = 0;
						this.getStoreList()
						break;
					case 1:
						// 线上订单
						this.sourceUrl = '';
						this.curr_page = 0
						this.getList()
						break;
					
					case 2:
						// 我的押金
						this.sourceUrl = '';
						this.curr_page = 0;
						this.getCashList();
						break;
					case 3:
						// 特殊押金
						this.sourceUrl = '';
						this.curr_page = 0;
						this.getOutProcessList();
						break;
				}
			},
			closePopup() {
				this.$refs['lossPopup'].close()
			},

			// 赔付弹框
			lossPayPop(id, productName, selfCustomAmount, cash, relatedType) {
				const _this = this
				_this.lossProductName = productName
				_this.lossOrderId = id
				_this.lossRelatedType = relatedType
				//console.log(selfCustomAmount)
				_this.lossSelfCustomAmount = parseInt(selfCustomAmount) > 0 ? selfCustomAmount : cash
				_this.$refs['lossPopup'].open()
			},

			lossPay() {
				const _this = this

				var opt = {
					url: '/order/lossPay',
					data: {
						id: _this.lossOrderId,
						related_type: _this.lossRelatedType
					},
					success: function(res) {
						//console.log(res)
						if (res.status == 1 && res.code == 0) {
							// #ifdef  H5
							jweixin.chooseWXPay({
								timestamp: res.data.list.timeStamp, // 支付签名时间戳，注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
								nonceStr: res.data.list.nonce_str, // 支付签名随机串，不长于 32 位
								package: 'prepay_id=' + res.data.list.prepay_id, // 统一支付接口返回的prepay_id参数值，提交格式如：prepay_id=\*\*\*）
								signType: 'MD5', // 签名方式，默认为'SHA1'，使用新版支付需传入'MD5'
								paySign: res.data.list.paySign, // 支付签名
								success: function(res) {
									// 支付成功后的回调函数
									if (res.errMsg == 'requestPayment:ok') {
										let options = {
											msg: '赔付成功',
											type: 'green'
										};
										_this.$refs.toast.showTips(options);
										//跳转支付成功页
										setTimeout(function() {
											// uni.reLaunch({
											// 	url: '/pages/pay/success/success?amount='+_this.editRentFee
											// });	
											_this.$refer.setVilit('/pages/pay/success/success')
											let callback = function(url) {
												_this.$refs.popupvLogin.open()
											}
											var data = {
												amount: _this.editRentFee
											}
											_this.$refer.toUrl(callback, data, 'reLaunch')
										}, 2000)

									}
								}
							});

							// #endif 
							// #ifdef  MP-WEIXIN  || APP-PLUS
							// _this.payment = res.data.list.payment
							// _this.order_no = res.data.list.order_no

							// #ifdef  APP-PLUS

							const orderInfo = JSON.stringify({
								appid: res.data.list.appid,
								noncestr: res.data.list.nonce_str,
								package: 'Sign=WXPay',
								partnerid: res.data.list.partnerid,
								prepayid: res.data.list.prepay_id,
								timestamp: res.data.list.timeStamp,
								sign: res.data.list.sign.substring(0, 30),
							})
							// #endif
							uni.requestPayment({
								provider: 'wxpay',
								// #ifdef  MP-WEIXIN
								timeStamp: res.data.list.timeStamp,
								nonceStr: res.data.list.nonce_str,
								package: 'prepay_id=' + res.data.list.prepay_id,
								signType: 'MD5',
								paySign: res.data.list.paySign,
								// #endif
								// #ifdef  APP-PLUS
								orderInfo: orderInfo,
								// #endif
								success: function(res) {

									if (res.errMsg == 'requestPayment:ok') {
										let options = {
											msg: '赔付成功',
											type: 'green'
										};
										_this.$refs.toast.showTips(options);
										//跳转支付成功页
										setTimeout(function() {
											// uni.reLaunch({
											// 	url: '/pages/pay/success/success?amount='+_this.editRentFee
											// });	
											_this.$refer.setVilit('/pages/pay/success/success')
											let callback = function(url) {
												_this.$refs.popupvLogin.open()
											}
											var data = {
												amount: _this.editRentFee
											}
											_this.$refer.toUrl(callback, data, 'reLaunch')
										}, 2000)

									}

								},
								fail: function(err) {
									console.log(err)
									//console.log('fail:' + JSON.stringify(err));
								}
							});
							// #endif 

						} else {

							let options = {
								msg: res.message,
								type: 'danger'
							};
							_this.$refs.toast.showTips(options);
							return;
						}


					}
				};

				_this.$service.GetApi(opt)
			},
			// 点击标题切换当前页时改变样式
			swichNav: function(e) {
				let cur = e.currentTarget.dataset.current;
				console.log('******cur:',cur)
				if (this.currentTab == cur) {
					return false;
				} else {

					if (cur == 1) {
						//待付款
						this.order_estate = 'pending_payment'
					}

					if (cur == 2) {

						//待发货
						this.order_estate ='paid'
					}

					if (cur == 3) {
						//待收货    配送中
						this.order_estate = 'shipping'
					}
					if (cur == 4) {
						//已签收 待评价
						this.order_estate = 'sign_for'
					}

					if (cur == 5) {
						//已完成
						this.order_estate = 'completed'
					}

					if (cur == 0) {
						//全部
						this.order_estate = ''
					}

					this.currentTab = cur
					this.curr_page = 0
					this.getList()
				}
			},
			swichNavTwo: function(e) {
				let cur = e.currentTarget.dataset.current;
				if (this.currentTab == cur) {
					return false;
				} else {

					if (cur == 1) {
						//已启用
						this.order_estate = 'used_pending_payment'
					}

					if (cur == 2) {
						//已完成
						this.order_estate = 'completed'
					}

					if (cur == 0) {
						//全部
						this.order_estate = ''
					}

					this.currentTab = cur
					this.curr_page = 0
					this.getStoreList()
				}
			},


			swichNavCash: function(e) {
				let cur = e.currentTarget.dataset.current;
				if (this.currentTab == cur) {
					return false;
				} else {

					if (cur == 1) {
						//绑定中
						this.order_estate = 'used_paid'
					}

					if (cur == 2) {
						//可提现
						this.order_estate = 'paid'
					}

					if (cur == 0) {
						//全部
						this.order_estate = ''
					}

					this.currentTab = cur
					this.curr_page = 0
					this.getCashList()
				}
			},
			swichNavOutProcess(e){
				let cur = e.currentTarget.dataset.current;
				this.currentTab = cur
				this.curr_page = 0;
				let obj={
					0:'',
					1:1,
					2:32
				}
				this.order_estate =obj[this.currentTab]
				console.log(this.currentTab)
				this.getOutProcessList()
				
				
			},

			
			getOutProcessList(){
				let _this=this;
				uni.showLoading({
					title: '加载中...',
					mask: false
				});
				uni.showNavigationBarLoading(); //显示加载动画							
				//提交ajax
				var opt = {
					url: '/order/getOutOrderList',
					data: {
						order_estate: _this.order_estate,//1待支付，32已支付
						page: ++_this.curr_page,
						
						// month:_this.monthList.key
					},
					success: function(res) {
						
						if (res.status == 1) {
							if (_this.curr_page == 1) {
								
								_this.data.list = res.data.list
								// console.log(_this.data.list)
								_this.loadingType = 2;
				
								_this.curr_page = res.data.page
								_this.last_page = res.data.last_page
								uni.hideNavigationBarLoading(); //关闭加载动画
								uni.stopPullDownRefresh(); //得到数据后停止下拉刷新
							} else {
				
								_this.data.list = _this.data.list.concat(res.data.list)
				
								_this.curr_page = res.data.page
								_this.last_page = res.data.last_page
				
								_this.loadingType = 2; //将loadingType归0重置
								uni.hideNavigationBarLoading(); //关闭加载动画
							}
				
							uni.hideLoading()
				
						} else {
							_this.data.list = []
							_this.loadingType = 3;
							uni.hideNavigationBarLoading(); //关闭加载动画
							uni.hideLoading()
						}
				
					}
				};
				
				_this.$service.GetApi(opt)
				
			},
			getCashList() {
				const _this = this

				uni.showLoading({
					title: '加载中...',
					mask: false
				});
				uni.showNavigationBarLoading(); //显示加载动画							
				//提交ajax
				var opt = {
					url: '/cash/getList',
					data: {
						order_estate: _this.order_estate,
						page: ++_this.curr_page,
						// month:_this.monthList.key
					},
					success: function(res) {
						
						if (res.status == 1) {
							if (_this.curr_page == 1) {
								
								_this.data.list = res.data.list
								// console.log(_this.data.list)
								_this.loadingType = 2;

								_this.curr_page = res.data.page
								_this.last_page = res.data.last_page
								uni.hideNavigationBarLoading(); //关闭加载动画
								uni.stopPullDownRefresh(); //得到数据后停止下拉刷新
							} else {

								_this.data.list = _this.data.list.concat(res.data.list)

								_this.curr_page = res.data.page
								_this.last_page = res.data.last_page

								_this.loadingType = 2; //将loadingType归0重置
								uni.hideNavigationBarLoading(); //关闭加载动画
							}

							uni.hideLoading()

						} else {
							_this.data.list = []
							_this.loadingType = 3;
							uni.hideNavigationBarLoading(); //关闭加载动画
							uni.hideLoading()
						}

					}
				};

				_this.$service.GetApi(opt)
			},
			getStoreList() {
				const _this = this
				uni.showLoading({
					title: '加载中...',
					mask: false
				});
				uni.showNavigationBarLoading(); //显示加载动画
				//提交ajax
				//console.log(1111)
				var opt = {
					url: '/order/orderList',
					data: {
						order_estate: _this.order_estate,
						page: ++_this.curr_page,
						// month:_this.monthList.key
					},
					success: function(res) {
						//console.log(res)

						if (res.status == 1) {
							if (_this.curr_page == 1) {
								_this.data.list = res.data.list
								_this.loadingType = 2;

								_this.curr_page = res.data.page
								_this.last_page = res.data.last_page
								uni.hideNavigationBarLoading(); //关闭加载动画
								uni.stopPullDownRefresh(); //得到数据后停止下拉刷新
							} else {
								_this.data.list = _this.data.list.concat(res.data.list)

								_this.curr_page = res.data.page
								_this.last_page = res.data.last_page

								_this.loadingType = 2; //将loadingType归0重置
								uni.hideNavigationBarLoading(); //关闭加载动画
							}
							uni.hideLoading()
						} else {
							_this.data.list = []
							_this.loadingType = 2;
							uni.hideNavigationBarLoading(); //关闭加载动画
							uni.hideLoading()
						}

					}
				};
				//console.log(333)
				_this.$service.GetApi(opt)
			},
			getList() {
				const _this = this
				uni.showLoading({
					title: '加载中...',
					mask: false
				});
				uni.showNavigationBarLoading(); //显示加载动画
				//提交ajax
				//console.log(1111)
				var opt = {
					url: '/order/orderShopList',
					data: {
						order_estate: _this.order_estate,
						page: ++_this.curr_page,
						// month:_this.monthList.key
					},
					success: function(res) {
						//console.log(res)

						if (res.status == 1) {

							if (_this.curr_page == 1) {
								_this.data.list = res.data.list
								_this.loadingType = 2;
								_this.curr_page = res.data.page
								_this.last_page = res.data.last_page
								uni.hideNavigationBarLoading(); //关闭加载动画
								uni.stopPullDownRefresh(); //得到数据后停止下拉刷新
							} else {
								_this.data.list = _this.data.list.concat(res.data.list)

								_this.curr_page = res.data.page
								_this.last_page = res.data.last_page

								_this.loadingType = 2; //将loadingType归0重置
								uni.hideNavigationBarLoading(); //关闭加载动画
							}
							uni.hideLoading()
						} else {

							_this.data.list = []
							_this.loadingType = 2;
							uni.hideNavigationBarLoading(); //关闭加载动画
							uni.hideLoading()
						}

					}
				};
				//console.log(333)
				_this.$service.GetApi(opt)
				console.log(this.data.list)
			},
			goShopDetail(row){
				let _this=this;
				_this.$refer.setVilit('/packageOnline/pages/product/shop_detail/shop_detail');
				let data={
					id:row.product_id
				}
				let callback = function(url) {
					_this.$refs.popupvLogin.open()
				}
				_this.$refer.toUrl(callback,data)
			},
			getPayStore(item,type) {
				this.couponObj = item;
				const _this = this
				// 清缓存
				_this.data.storeaddress = []
				if(type=='store'){
					console.log('123456',item)
					 //后台手动创建门店租赁订单 未付款
					 if(item.channel==5 && item.order_estate=='pending_payment'){
						  _this.$refer.setVilit('/packageOrder/pages/store/storeRentPay')
					 }else{
						 _this.$refer.setVilit('/packageOrder/pages/store/returnProduct')
					 }
					 
				}else if(type == 'monthcard'){
					_this.$refer.setVilit('/packageStore/pages/month_card/buy_month_card/buy')
				}
				else{
					_this.$refer.setVilit('/packageOrder/pages/online/returnProduct')
				}

				
				let callback = function(url) {
					_this.$refs.popupvLogin.open()
				}

				var data = item;
				if(type == 'monthcard'){
					 data = {
						 class_id:item.class_id,
						 is_renew:1,
						 month_order_id:item.month_card_order_id,
						 
					 }
						 
					 
				}
				if(item.channel==5){
					 
					data = item;
					data.bid = item.business_id;
					data.cid = item.class_id;
					data.storeaddressId = item.store_id;
					data.storeName = item.store_name; 
					data.selectMonthCard=JSON.stringify([]);
					data.usableCash = '' 
					data.user_month_card=JSON.stringify(item.userMonthCard);
					data.monthcard_pay=item.userMonthCard.status;
					data.isMonthCardPay = !item.userMonthCard.status ? 'noPay' : 'pay';
					// console.log('-*-*-*',data)
					// return ;
				}
			 
				// return false;
				_this.$refer.toUrl(callback, data)

			},
			
			pendingRefund(desStr){
				//申请退押金
				const _this = this
				desStr = _this.$service.decryptDes(desStr)
				let orderNo = _this.$service.decryptDes(desStr)
				orderNo = _this.$service.encryptDes(orderNo)
				// console.log(orderNo)
				uni.showModal({
				    title: '提示',
				    content: '是否确定提现?',
				    success: function (res) {
				        if (res.confirm) {
				            var opt={
				            	url:'/cash/pendingRefund',
				            	data:{
				            		order_no:orderNo				
				            	},
				            	success:function(res){
				            		//console.log(res)
				            		if(res.status==1){
				            			let options = {
											msg: '提交申请成功',
											type:'green'
				            			};						
										_this.$refs.toast.showTips(options);
										_this.curr_page = 0
										_this.getList()
				            		}else{
				            			 let options = {
											msg: res.message,
											type:'danger'
										  };								
										_this.$refs.toast.showTips(options);
				            		
				            		}
				            									
				            	}
				            };
				            						
				            _this.$service.GetApi(opt)	
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
				
				
			},
			receive(row){
				let _this=this;
				var opt = {
					url: '/order/takeGoods',
					data: {
						trade_no:row.trade_no
					},
					success: function(res) {
						//console.log(res)
				
						if (res.status == 1) {
							_this.curr_page = 0;
							_this.getList();

						} else {

							uni.hideNavigationBarLoading(); //关闭加载动画
							uni.hideLoading()
						}
				
					}
				};

				_this.$service.GetApi(opt)
			},
			camera() {
				const _this = this
				if (!_this.loginStatus) {
					_this.$refer.setVilit('local')
					let callback = function(url) {

						_this.$refs.popupvLogin.open()

					}

					_this.$refer.toUrl(callback, {}, 'local')
				} else {
					//授权手机    必须
					//console.log('camera')
					//#ifdef  H5
					//console.log(99)
					jweixin.getLocation({
						type: 'gcj02', // 默认为wgs84的gps坐标，如果要返回直接给openLocation用的火星坐标，可传入'gcj02'
						success: function(res) {
							_this.latitude = res.latitude; // 纬度，浮点数，范围为90 ~ -90
							_this.longitude = res.longitude; // 经度，浮点数，范围为180 ~ -180。

							// if(_this.data.userInfo.mobile===''&&_this.data.userInfo.ali_mobile==='')
							// {					
							// 	return
							// }
							jweixin.scanQRCode({
								needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
								scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码，默认二者都有
								success: function(res) {
									let url = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
									//门店id
									const sid = _this.getQueryVariable('sid', url)

									//商品supply_id  其它时候是商品id
									const pid = _this.getQueryVariable('pid', url)

									//商家id
									const bid = _this.getQueryVariable('bid', url)

									//产品类型id
									const cid = _this.getQueryVariable('cid', url)


									_this.getProduct(sid, pid, bid, cid)
								}
							});
						}
					});



					//#endif	

					//#ifdef  MP-WEIXIN || MP-ALIPAY ||APP-PLUS

					uni.getLocation({
						//#ifdef  MP-WEIXIN ||APP-PLUS
						type: 'gcj02', //返回可以用于uni.openLocation的经纬度
						//#endif

						success: function(res) {

							_this.latitude = res.latitude;
							_this.longitude = res.longitude;
							// 记得关掉
							// _this.latitude = 22.797131;
							// _this.longitude = 108.339878;
							//22.797131,108.339878

							// if(_this.data.userInfo.mobile===''&&_this.data.userInfo.ali_mobile==='')
							// {

							// 	return
							// }

							uni.scanCode({
								onlyFromCamera: true,
								success: function(res) {
									//console.log(res)
									//console.log('条码类型：' + res.scanType);
									const code = res.result
									// console.log('条码内容：' + res.result);
									if (res.scanType == 'EAN_13') {
										//console.log(code)
										//条形码     进入产品绑定页
										// uni.navigateTo({
										//     url: '../after_sales/manager/manager?code='+code
										// });

										// return
										console.log(code)
										_this.$refer.setVilit('/pages/after_sales/manager/manager')
										let callback = function(url) {
											_this.$refs.popupvLogin.open()
										}
										var data = {
											code: code
										}

										_this.$refer.toUrl(callback, data)
										return
									}

									if (res.scanType == 'QR_CODE') {
										//门店id
										const sid = _this.getQueryVariable('sid', code)

										//商品supply_id  其它时候是商品id
										const pid = _this.getQueryVariable('pid', code)

										//商家id
										const bid = _this.getQueryVariable('bid', code)

										//产品类型id
										const cid = _this.getQueryVariable('cid', code)


										_this.getProduct(sid, pid, bid, cid)
										// _this.seleteStore(sid,pid,bid,cid)
										return
									}


								}
							});

						},
						fail: function(res) {
							let options = {
								msg: 'GPS未开启',
								type: 'danger'
							};
							_this.$refs.toast.showTips(options);
							_this.cashModal = true

							return
						}
					});
					//#endif
				}
			},



		}
	}
</script>

<style lang="scss" scoped>
	@import "./order_list_center.scss";
</style>
